﻿#include <opencv4/opencv2/opencv.hpp>
#include <iostream>
#include<memory>
#include"serials/Inc/serial.h"
#include"task/Inc/task.h"

using namespace std;
using namespace cv;
//若阅读代码有困难参考百度搜索“设计模式-----状态模式”

class Work;
//状态模式   抽象类
class State
{
public:
    State();
//开启程序，实现该状态下的任务
    virtual void startProgram(Work &w , Serial serial,Mat &srcBottom,Mat &srcUp) = 0;
    shared_ptr<Operation> getTaskOperation();
protected:
    shared_ptr<Operation> _taskOperation;
    shared_ptr<TaskFactory> _taskFactory;
};
//装甲板射击状态
class ArmorState : public State
{
public:
    virtual void startProgram(Work &w , Serial serial,Mat &srcBottom,Mat &srcUp) override;
private:
    Point2f _shootPos;
};
//神符射击状态
class BuffState : public State
{
public:
    virtual void startProgram(Work &w , Serial serial,Mat &srcBottom,Mat &srcUp) override;
private:
    Point2f _shootPos;
};
//无任务状态
class NoState : public State
{
public:
    virtual void startProgram(Work &w , Serial serial,Mat &srcBottom,Mat &srcUp) override;
private:
};

class Work
{
public:
    Work()
    {
        //初始化状态为装甲版射击
        _state = make_shared<ArmorState>();
    }
    ~Work()
    {

    }
    void startProgram(Serial serial,Mat &srcBottom,Mat &srcUp)
    {
        _state->startProgram(*this , serial,srcBottom,srcUp);
    }
    shared_ptr<State> getState();
    //设置状态
    void setState(shared_ptr<State>  s);
    int _task;
    int _shootTask; 
private:
    shared_ptr<State>  _state;
};
